package com.pinyoumei.app.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.pinyoumei.app.R;

/**
 * 兑换油卡的Dialog
 */
public class MyOilExchangeDialog extends Dialog{
    private Context context;
    private int layoutResID;      // 布局文件id



    public MyOilExchangeDialog(Context context, int layoutResID){
        super(context, R.style.dialogStyle); //dialog的样式
        this.context = context;
        this.layoutResID = layoutResID;


    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window dialogWindow = getWindow();
        dialogWindow.setGravity(Gravity.CENTER);//内部区域显示在中间
        //dialogWindow.setWindowAnimations(R.style.bottom_menu_animation);
        WindowManager.LayoutParams  lp = dialogWindow.getAttributes();
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();//获取屏幕宽高
        lp.width = (int)(displayMetrics.widthPixels * 0.9);//宽度设置为屏幕宽度的80%
        dialogWindow.setAttributes(lp);
        setCanceledOnTouchOutside(true);//点击Dialog外部消失
        setContentView(layoutResID);



    }



}
